package com.hmsg.health.param;

import com.hmsg.health.bean.enums.CodeEnum;
import com.hmsg.health.bean.enums.StatusCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel
public class ResponseResult<T> {
	@ApiModelProperty(value = "状态码")
	private Integer returnCode;
	private String message;
	private T data;


	/**
	 * 生成内容为空的ResponseResult
	 * @param isClean
	 */
	public ResponseResult(boolean isClean) { 
	}

	/**
	 * 生成带有默认值
	 */
	public ResponseResult() {
		new ResponseResult(StatusCode.SYSTEM_WAIT,null);
	}

	public ResponseResult(CodeEnum code) {
		this.returnCode = code.getCode();
		this.message = code.getMessage();
	}

	public ResponseResult(int code, String message) {
		this.returnCode = code;
		this.message = message;
	}

	public ResponseResult(CodeEnum code, T data) {
		this.returnCode = code.getCode();
		this.message = code.getMessage();
		this.data = data;
	}

	public ResponseResult(Integer returnCode, String message, T data) {
		this.returnCode = returnCode;
		this.message = message;
		this.data = data;
	}

	public static <T> ResponseResult<T> build(int code,String message,T data){
		ResponseResult<T> result = new ResponseResult<>();
		result.setReturnCode(code);
		result.setMessage(message);
		result.setData(data);
		return result;
	}

	public static <T> ResponseResult<T> success(T data){
		ResponseResult<T> result = new ResponseResult<>(StatusCode.SYSTEM_SUCCESS);
		result.setData(data);
		return result;
	}


	public static <T> ResponseResult<T> order_success(T data){
		ResponseResult<T> result = new ResponseResult<>(StatusCode.SYSTEM_ORDER_SUCCESS);
		result.setData(data);
		return result;
	}

	public void setReturnCode(int code){
		this.returnCode = code;
	}
	public void setReturnCode(CodeEnum code) {
		this.returnCode = code.getCode();
		this.message = code.getMessage();
	}


}
